#include <unittest++/UnitTest++.h>
#include <Ape/Ext/SharedLibrary.h>
#include <Ape/Exception.h>
#include <ApeTest/testPluginBase.h>


namespace ApeTest {
	namespace Ext {
		using Ape::Ext::SharedLibrary;
		
		TEST (Ape_Ext_SharedLibrary__BasicTest) {
			try {
				SharedLibrary shLib (L"/home/romko/Documents/Sources/ApeSolution/Ape/lib/libtestSharedLib.so");
				typedef void (*void_f_noargs) ();
				void_f_noargs f = shLib.ResolveTyped<void_f_noargs> (L"testFunction");
				f();
			}
			catch (Ape::Exception& exc) {
				exc._Dump (true);
				CHECK_EQUAL (1, 0);
			}
		}
		
		TEST (Ape_Ext_SharedLibrary__ObjectActivation) {
			try {
				SharedLibrary shLib (L"/home/romko/Documents/Sources/ApeSolution/Ape/lib/libtestSharedLib.so");
				Ape::Object* obj = shLib.Activate(L"TestLib::TestClass");
				del(obj);
				
				//ApeTest::TestPluginBase* plugin = shLib.ActivateTyped<ApeTest::TestPluginBase>(L"TestLib::TestPluginDerivative");
				//shLib.DisposeObject(plugin);
			}
			catch (Ape::Exception& exc) {
				exc._Dump(true);
				CHECK_EQUAL (1, 0);
			}
		}
	}
}

